import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:get/get.dart';
import 'package:xinxuan/utils/integral_type_util.dart';
import 'package:xinxuan/vo/integral_detail_vo.dart';

/// 积分详情弹窗
class IntegralsDetailDialog extends Dialog {

  final IntegralDetailData data;

  IntegralsDetailDialog({ required this.data });

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Stack(
          children: [
            Container(
              padding: EdgeInsets.symmetric(vertical: 32.h),
              width: 320.w,
              // height: 258.w,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(12.w),
                color: bgWhiteColor
              ),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  Container(
                    width: 320.w,
                    padding: EdgeInsets.only(bottom: 21.h),
                    decoration: BoxDecoration(
                      border: Border(
                        bottom: BorderSide(
                          width: 1,
                          color: lineColor
                        )
                      )
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Image.asset(
                              IntegralTypeUtil.getIntegralTypeIcon(data.type!),
                              width: 36.w,
                              height: 36.w,
                            ),
                            SizedBox(width: 12.w),
                            Text(
                              '${data.typeStr}',
                              style: TextStyle(
                                fontSize: 16.sp,
                                fontWeight: FontWeight.bold
                              ),
                            )
                          ],
                        ),
                        SizedBox(height: 6.h),
                        Text(
                          '${data.integral}',
                          style: TextStyle(
                            fontSize: 21.sp,
                            color: data.operator! > 0 ? textColorIntegralAdd : mainTextColor
                          ),
                        )
                      ],
                    ),
                  ),
                  Container(
                    padding: EdgeInsets.symmetric(horizontal: 23.w),
                    child: Column(
                      children: data.orders!.map((item) {
                        return Container(
                          margin: EdgeInsets.only(top: 12.h),
                          child: Row(
                            children: [
                              Text(
                                '${item.label} : ',
                                style: TextStyle(
                                  color: textSubtitleColor,
                                  fontSize: 14.sp
                                ),
                              ),
                              Text(
                                '${item.value}',
                                style: TextStyle(
                                  color: textBlackColor,
                                  fontSize: 14.sp
                                ),
                              )
                            ],
                          ),
                        );
                      }).toList(),
                    ),
                  )
                ],
              ),
            ),
            Positioned(
              top: 16.w,
              right: 16.w,
              child: InkWellUtil.shakeProofInkWell(Image.asset(
                'assets/icons/icon_close.png',
                width: 16.w,
                height: 16.w,
              ), () {
                Get.back();
              })
            )
          ],
        ),
      ),
    );
  }
}